define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'roomcardcode/clubdiamond/index',
                    table: 'c_club_diamond_log',
                }
            });

            var table = $("#table");

        	table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                     	{field: 'name', title: __('Name'),searchable:false},
						{field: 'clubid', title: __('Clubid')},
						{field: 'clubtype', title: __('Clubtype'), searchList: {'1':'普通', '2': 'VIP'}},
						{field: 'owner', title: __('Owner'),searchable:false},
						{field: 'ownername', title: __('Ownername'),searchable:false},
						{field: 'type', title: __('账变类型'), searchList: {'1':'创建俱乐部', '2': '补充房卡', '3': '解散俱乐部'}},
						{field: 'diamond', title: __('Diamond'),searchable:false},
						{field: 'newdiamond', title: __('Newdiamond'),searchable:false},
						{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD HH:mm:ss"', style: 'min-width:90px;'},
                    ]
                ],
                
                onLoadSuccess: function (data) {
					$("#statistics").html(
							'<a class="btn btn-danger">创建俱乐部房卡：' + data.statistics.type_one + '</a>&nbsp;' 
							+ '<a class="btn btn-info">补充俱乐部房卡：' + data.statistics.type_two + '</a>&nbsp;' 
							+ '<a class="btn btn-success">解散退还房卡：' + data.statistics.type_three + '</a>&nbsp;' 
							);
                	$("#statistics").show();
                }
                
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});